<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
    </head>
    <body>
    <script type="text/javascript">
        var Demo=function(){
            if(!(this instanceof Demo)){
                return new Demo()
            }
        }
        Demo.prototype.show=function(){
            console.log('success')
        }
        var d=Demo()
        d.show()
        console.log(d.__proto__.__proto__==Object.prototype)
        console.log(Function.__proto__==Function.prototype)
        console.log(Object.prototype)
        function Js(content){
            this.content=content;
            console.log(this)
            console.log(content)
        }
        var j=new Js('123')
        console.log(j)

        var Factory=function(type,content){
            if(this instanceof Factory){
                var s=new this[type](content)
                return s
            }else{
                return new Factory(type,content)
            }
        }
        
        Factory.prototype={
            Java:function(content){

            },
            Js:function(content){

            },
            PHP:function(content){
                console.log(content)
            },
            Ui:function(content){

            }
        }
        var f=new Factory('Ui','blue')
        console.log(f)
        var data=[
        {type:'Js',content:'js哪家强'},
        {type:'Java',content:'Java哪家强'},
        {type:'PHP',content:'PHP哪家强'},
        ]
        for(var i=0;i<data.length;i++){
            var f= Factory(data[i].type,data[i].content)
            console.log(f)
            // f()
        }
    </script>
    </body>
</html>